package dao;

import entity.User;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class UserDao implements UserDaoInterface {
    @Override
    public void login(Connection connection, User user) throws SQLException {
        String sql_login="select * from user where username=? and password=?";
        PreparedStatement pstmt_login = connection.prepareStatement(sql_login);
        pstmt_login.setString(1, user.getUsername());
        pstmt_login.setString(2, user.getPassword());
        ResultSet rs_login = pstmt_login.executeQuery();
        if(rs_login.next()){
            long user_id = rs_login.getLong("id");
            user.setId(user_id);
        }
    }
}
